Skip to content

Checkout update #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Checkout update #292

wants to merge 4 commits into from

Conversation

jamill
Copy link
Member

@jamill jamill commented Jan 9, 2013

This PR updates LibGit2Sharp in response to the recent checkout updates in libgit2. We now call git_checkout_tree and then update head so that checkout can take into account the current working directory, current head, and the target commit.

This also re-enables a reset test which was temporarily disabled.

string fullPath = Path.Combine(repo.Info.WorkingDirectory, fileFullPath);
File.WriteAllText(fullPath, originalFileContent);
repo.Index.Stage(fullPath);
repo.Commit("change in master");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended to add some Signatures. Otherwise, LibGit2Sharp will try to infer the identity of the author/committer from the global config (which may not exist).

Changing this would make the Travis build pass, for instance 😉

@nulltoken
Copy link
Member

@jamill I love it. The code is very clean!

@jamill
Copy link
Member Author

jamill commented Jan 10, 2013

@nulltoken Thanks for the review! will update based on your feedback shortly

File.WriteAllText(ignoredFilePath, "hello from this ignored file.");

// The following check does not report ignored entries...
// Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that Index.RetrieveStatus() does not return Ignored entries? Is this expected? If so, what does the Ignored property represent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatusFixture has passing tests around ignored files, so it would surprise me that this assert fails but the following one passes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...

I've got the following test unexpectedly failing 😢. On it.

[Fact]
public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroughoutDirectories()
{
    TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
    using (var repo = new Repository(path.RepositoryPath))
    {
        string ignoredDirectoryPath = Path.Combine(repo.Info.WorkingDirectory, "bin");
        Directory.CreateDirectory(ignoredDirectoryPath); 

        string relativePath = Path.Combine("bin", "look-ma.txt");
        string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
        File.WriteAllText(fullFilePath, "I'm going to be ignored!");

        string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore");
        File.WriteAllText(gitignorePath, "bin");

        RepositoryStatus newStatus = repo.Index.RetrieveStatus();

        Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath));
        Assert.Equal(new[] { relativePath }, newStatus.Ignored);
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nulltoken Yes, I think that is the same (unexpected) behavior I noticed.

@jamill
Copy link
Member Author

jamill commented Jan 22, 2013

Rebased and updated as per discussion.

@nulltoken
Copy link
Member

And merged!

✨ ✨ ✨ ✨ ✨ ✨ ✨

@nulltoken nulltoken closed this Jan 22, 2013
@jamill
Copy link
Member Author

jamill commented Jan 22, 2013

@nulltoken Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants